# Maintainer: Massimiliano Torromeo <massimiliano.torromeo@gmail.com>
# Contributor: Aleksandar Trifunović <akstrfn at gmail dot com>

pkgname=abseil-cpp
pkgver=20230125.1
pkgrel=2
pkgdesc="Collection of C++ library code designed to augment the C++ standard library"
arch=('loong64' 'x86_64')
url='https://abseil.io'
license=('Apache')
makedepends=('cmake' 'gtest')
source=("https://github.com/abseil/abseil-cpp/archive/$pkgver/$pkgname-$pkgver.tar.gz"
         scoped-mock-log.patch
         abseil-cpp-la64.patch)
sha256sums=('81311c17599b3712069ded20cca09a62ab0bf2a89dfa16993786c8782b7ed145'
            'a6cbc612a2b96fcbd52d081e03e8581107ceb4827edb19d96510a31c568e1396'
            '8817cf256a94dd9059bccd540a4d6bbe0d9606c600e8543a1b1011226c350b23')

prepare() {
  cd "$srcdir/$pkgname-$pkgver"
  patch -p1 -i ../scoped-mock-log.patch # Install target needed by protobuf
  patch -p1 -i $srcdir/abseil-cpp-la64.patch
}

build() {
  cd "$srcdir/$pkgname-$pkgver"
  cmake -Bbuild \
    -DCMAKE_BUILD_TYPE=RelWithDebInfo \
    -DCMAKE_CXX_FLAGS="-DNDEBUG" \
    -DCMAKE_INSTALL_PREFIX=/usr \
    -DCMAKE_CXX_STANDARD=17 \
    -DBUILD_SHARED_LIBS=ON \
    -DABSL_BUILD_TEST_HELPERS=ON \
    -DABSL_USE_EXTERNAL_GOOGLETEST=ON \
    -DABSL_FIND_GOOGLETEST=ON \
    -DCMAKE_POSITION_INDEPENDENT_CODE=ON
  cd build
  cmake --build .
}

package() {
  cd "$srcdir/$pkgname-$pkgver/build"
  DESTDIR="$pkgdir" cmake --install .
}
